const state = {
    query: '',
    history: []
}

const getters = {
    query: state => state.query,
    history: state => state.history
}

const mutations = {
    setQuery: (state,query) => state.query = query,
    addHistory: (state,record) => {
        if (!state.history.includes(record))
            state.history.unshift(record)
    },
    removeHistory: (state,index) => {
        state.history.splice(index,1)
    },
    clearHistory: state => state.history = []
}

const actions = {

}

export default {
    namespaced: true,
    state,
    getters,
    mutations,
    actions
}
